<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>检测内存泄漏</p>
    <button id="startbtn">开始模拟内存泄漏</button>

    <script>
        const startbtn = document.querySelector('#startbtn')
        let arr = []
        for(let i = 0;i<10 * 10000;i++){
            arr.push(i)
        }

        const bind = ()=>{
            const obj = {
                data:JSON.stringify(arr)
            }

            window.addEventListener('resize',()=>{
                console.log('resize',obj)
            })
        }

        const start = ()=>{
            let n = 0;
            setInterval(()=>{
                if(n<=50){
                    bind()
                    n++
                }else{
                    alert('结束了')
                }
            },200)
        }

        startbtn.addEventListener('click',()=>{
            start()
        })


    </script>
</body>
</html>